package com.ninetaildemonfox.zdl.socialproject.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;

import com.hyphenate.chat.EMClient;
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialog.util.BaseDialog;
import com.kongzue.dialog.v3.MessageDialog;
import com.ninetaildemonfox.zdl.socialproject.base.BaseActivity;
import com.ninetaildemonfox.zdl.ninetaildemonfox.utils.AppManager;
import com.ninetaildemonfox.zdl.socialproject.R;
import com.ninetaildemonfox.zdl.socialproject.mvp.presenter.SelectiveSexPresenter;
import com.ninetaildemonfox.zdl.socialproject.utils.dialog.DialogShow;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author NineTailDemonFox
 * @date 2019/7/17 13:08
 * 功能描述： 选择性别
 * 联系方式：1037438704@qq.com
 */

public class SelectiveSexActivity extends BaseActivity {
    @BindView(R.id.image_left_finish)
    ImageView imageleftFinish;
    @BindView(R.id.text_center)
    TextView textCenter;
    @BindView(R.id.text_right)
    TextView textRight;
    @BindView(R.id.text_confirm)
    TextView textConfirm;
    @BindView(R.id.radio_button_girl)
    RadioButton radioButtonGirl;
    @BindView(R.id.radio_button_boy)
    RadioButton radioButtonBoy;
    private int sexChecked = 0;
    private View inflate;
    private TextView text_center, text_parent;
    private AlertDialog.Builder dialogShow;
    private SelectiveSexPresenter selectiveSexPresenter;
    private int count;


    @Override
    protected int getLayoutResource() {
        return R.layout.activity_selective_sex;
    }

    @Override
    protected void onInitialization(Bundle bundle) {
        initData();
    }

    private void initData() {
        imageleftFinish.setVisibility(View.VISIBLE);
        textCenter.setText("选择性别");
    }

    @OnClick({R.id.image_left_finish, R.id.text_confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.image_left_finish:
                //立即开通
                MessageDialog.show(me, "是否确认退出？", "", "确认", "取消")
                        .setOnOkButtonClickListener(new OnDialogButtonClickListener() {
                            @Override
                            public boolean onClick(BaseDialog baseDialog, View v) {
                                EMClient.getInstance().logout(true);
                                AppManager.getInstance().killActivity(MainActivity.class);
                                startActivity(new Intent(me, LoginActivity.class));
                                finish();
                                return false;
                            }
                        });
                break;
            case R.id.text_confirm:
                if (radioButtonGirl.isChecked() == true) {
                    count = 2;
                }
                if (radioButtonBoy.isChecked() == true) {
                    count = 1;
                }
                if (count == 0) {
                    Toast.makeText(this, "请选择性别", Toast.LENGTH_SHORT).show();
                    return;
                }
                DialogShow.start(this, count + "");
//                selectiveSexPresenter.getEditSex(token, count + "");
                break;
            default:
        }
    }


    @Override
    public void onBackPressed() {
        //立即开通
        MessageDialog.show(me, "是否确认退出？", "", "确认", "取消")
                .setOnOkButtonClickListener(new OnDialogButtonClickListener() {
                    @Override
                    public boolean onClick(BaseDialog baseDialog, View v) {
                        EMClient.getInstance().logout(true);
                        AppManager.getInstance().killActivity(MainActivity.class);
                        startActivity(new Intent(me, LoginActivity.class));
                        finish();
                        return false;
                    }
                });
    }
}
